# Maintainer: Kyle Keen <keenerd@gmail.com?>
# Contributor: Dominik Heidler <dheidler@gmail.com>

_name=gr-osmosdr
pkgname=gnuradio-osmosdr
pkgver=0.2.4
_commit=09257669f52605e2dad71e4035d7a3d73121ac68  # refs/tags/v0.2.4
pkgrel=5
pkgdesc='Source block for Funcube Dongle, RTL-SDR, USRP, OsmoSDR, BladeRF, HackRF and AirSpy devices'
url='https://osmocom.org/projects/gr-osmosdr'
arch=(loong64 x86_64)
license=(GPL3)
depends=(
  airspy
  bladerf
  gcc-libs
  glibc
  hackrf
  libuhd
  libvolk
  soapysdr
  rtl-sdr
)
makedepends=(
  cmake
  boost
  git
  gnuradio
  gnuradio-iqbal
  pybind11
)
optdepends=('python-opengl: for osmocom_fft')
provides=(libgnuradio-osmosdr.so)
replaces=('gr-osmosdr')
source=(git+https://gitea.osmocom.org/sdr/$_name.git#tag=$_commit)
sha256sums=('SKIP')

build() {
  local cmake_options=(
    -B build
    -D CMAKE_BUILD_TYPE=None
    -D CMAKE_INSTALL_PREFIX=/usr
    -D Boost_NO_BOOST_CMAKE=ON
    -D ENABLE_AIRSPY=ON
    # -D ENABLE_AIRSPYHF=ON  # TODO: package https://github.com/airspy/airspyhf
    -D ENABLE_BLADERF=ON
    # -D ENABLE_FCD=ON  # TODO: package https://github.com/dl1ksv/gr-funcube
    -D ENABLE_FILE=ON
    # -D ENABLE_FREESRP=ON  # TODO: package https://github.com/myriadrf/libfreesrp
    -D ENABLE_HACKRF=ON
    -D ENABLE_IQBALANCE=ON
    # -D ENABLE_MIRI=ON  # TODO: package https://gitea.osmocom.org/sdr/libmirisdr
    -D ENABLE_PYTHON=ON
    -D ENABLE_REDPITAYA=ON
    -D ENABLE_RFSPACE=ON
    -D ENABLE_RTL=ON
    -D ENABLE_RTL_TCP=ON
    -D ENABLE_SOAPY=ON
    -D ENABLE_UHD=ON
    # -D ENABLE_XTRX=ON  # TODO: package https://github.com/xtrx-sdr/libxtrx
    -S $_name
    -W no-dev
  )

  cmake "${cmake_options[@]}"
  cmake --build build
}

package() {
  depends+=(
    boost-libs libboost_{chrono,thread}.so
    gnuradio libgnuradio-{blocks,runtime,pmt,uhd}.so
    gnuradio-iqbal libgnuradio-iqbalance.so    
  )

  DESTDIR="$pkgdir" cmake --install build
}
